package com.ae.shield.client.events;

import com.ae.shield.client.block.tileEntityRenderer.AssemblyBlockTER;
import com.ae.shield.client.block.tileEntityRenderer.ProgrammerBlockTER;
import com.ae.shield.client.block.tileEntityRenderer.ShieldWorkbenchBlockTER;
import com.ae.shield.common.block.BlockList;
import com.ae.shield.common.block.tile.TileEntityList;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.RenderTypeLookup;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.client.registry.ClientRegistry;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;

@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
public class BlockRender {
    @SubscribeEvent
    public static void renderTranslucent(FMLClientSetupEvent event) {
        event.enqueueWork(() -> {
            RenderTypeLookup.setRenderLayer(BlockList.ASSEMBLY_BLOCK.get(), RenderType.getTranslucent());
            RenderTypeLookup.setRenderLayer(BlockList.NANO_ROBOT_PROGRAMMER.get(), RenderType.getTranslucent());
            RenderTypeLookup.setRenderLayer(BlockList.SHIELD_WORKBENCH_BLOCK.get(), RenderType.getTranslucent());
        });
    }

    /**
     * 处理方块的特殊渲染
     * 如：在方块上渲染物品
     */
    @SubscribeEvent
    public static void TER(FMLClientSetupEvent event) {
        event.enqueueWork(() -> {
            ClientRegistry.bindTileEntityRenderer(TileEntityList.ASSEMBLY_ENTITY.get(), AssemblyBlockTER::new);
            ClientRegistry.bindTileEntityRenderer(TileEntityList.NANO_ROBOT_PROGRAMMER_TILE.get(), ProgrammerBlockTER::new);
            ClientRegistry.bindTileEntityRenderer(TileEntityList.SHIELD_WORKBENCH_TILE.get(), ShieldWorkbenchBlockTER::new);
        });
    }
}
